package org.sean.framework.schedule.endpoint;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.sean.framework.schedule.ScheduleJob;
import org.sean.framework.schedule.server.ScheduleServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by linKe on 2020/6/3.
 *
 * @see ScheduleJobsEndpoint
 */
@Deprecated
@RestController
@Tag(name = "定时任务")
public class GreeterHttpController {
    @Autowired
    ScheduleServer scheduleServer;

    /**
     * 定时任务http调用接口
     *
     * @param job job
     * @return 调用结果
     */
    @Operation(summary = "执行定时任务",
            description = "执行定时任务",
            responses = {
                    @ApiResponse(description = "执行结果",
                            content = @Content(mediaType = "application/json",
                                    schema = @Schema(implementation = ScheduleJob.class)
                            ))})
    @PostMapping("/job/message")
    public String messageForHttp(@RequestBody ScheduleJob job) {
        return scheduleServer.receive(job);
    }
}
